// <%@ page contentType="text/html;charset=UTF-8" %>
<script type='text/javascript'>
top.$.rootUrl = '${ctxStatic}'
var acceptClick;
var keyValue = request('keyValue');
(function ($, learun) {
    "use strict";
    //var selectedRow = learun.frameTab.currentIframe().selectedRow;
    var page = {
        init: function () {
            $('.lr-form-wrap').mCustomScrollbar({ theme: "minimal-dark" });
            page.bind();
            //page.initData();
        },
        bind: function () {
            // $('#SYS_NAME').lrDataItemSelect({ code: 'DbVersion' });
            // $('#TABLE_TYPE').lrDataItemSelect({ code: 'DbVersion' });
            // $('#INTERFACE_NAME').lrDataItemSelect({ code: 'DbVersion' });
        },
        initData: function () {
            if (!!keyValue) {
                $.lrSetForm(top.$.rootUrl + '/LR_CodeDemo/DataInterface/GetFormData?keyValue=' + keyValue, function (data) {
                    for (var id in data) {
                        if (!!data[id].length && data[id].length > 0) {
                        }
                        else {
                            $('[data-table="' + id + '"]').lrSetFormData(data[id]);
                        }
                    }
                });
            }
        }
    };
    // 保存数据
    acceptClick = function (callBack) {
        if (!$('body').lrValidform()) {
            return false;
        }
        var postData = {
            strEntity: JSON.stringify($('body').lrGetFormData())
        };
        alert(JSON.stringify(postData))
        learun.httpPost('${ctx}/sys/datainterface/SaveForm?keyValue=' + keyValue, postData, function (res) {
            // 保存成功后才回调
            if (!!callBack) {
                callBack();
            }
            learun.layerClose(window.name);
        });
    };
    page.init();

})(window.jQuery, top.learun);
</script>